package com.guoxin.chapter3.waitnotify.waitnotifyinsettest;

public class DBTools {
	private volatile boolean preIsA = false;
	
	public synchronized void backupA(){
		try {
			while(preIsA){
				this.wait();
			}
			for(int i=0;i<5;i++){
				System.out.println("★★★★★");
			}
			preIsA = true;
			this.notifyAll();
		} catch (InterruptedException e) {
			e.printStackTrace();
		}
	}
	
	public synchronized void backupB() {
		try {
			while (!preIsA) {
				this.wait();
			}
			for (int i = 0; i < 5; i++) {
				System.out.println("☆☆☆☆☆");
			}
			preIsA = false;
			this.notifyAll();
		} catch (InterruptedException e) {
			e.printStackTrace();
		}
	}
}
